package net.zjitc.dao;

import net.zjitc.domain.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookDao {
    @Select("select * from books;")
    List<Book> findAll();

    @Insert("insert into books (name,isbn,author,price,press) values (#{name},#{isbn},#{author},#{price},#{press});")
    int insert(Book book);

    @Delete("delete from books where id=#{id};")
    int delete(int id);

    @Update("update books set name =#{name}," +
            "isbn=#{isbn}," +
            "author=#{author}," +
            "price=#{price}," +
            "press=#{press}  where id=#{id};")
    int update(Book book);

    @Select("select * from books where id =#{id};")
    Book findById(int id);

    List<Book> findByCondition(Book book);
}
